﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ascx_StatusBar : System.Web.UI.UserControl
{
    #region Variables

    private string _caption;
    private string _message;
    private StatusType _statusType;
    private bool _modal;
    private bool _showClose;
    private bool _showOkButton;



    public enum StatusType
    {
        Warning, Success, Error, Information
    }

    #endregion

    #region Properties

    public string Caption
    {
        get { return _caption; }
        set
        {

            _caption = value;
            ltrStatusCaption.Text = value;

        }
    }

    public string Message
    {
        get { return _message; }
        set
        {
            _message = value;
            ltrStatusMessage.Text = value;

        }
    }

    public StatusType Type
    {
        get { return _statusType; }
        set
        {

            _statusType = value;

            switch (_statusType)
            {
                case StatusType.Warning:
                    pnStatusBar.CssClass = "status warning";
                    this.Caption = "Atenção! ";
                    imgStatus.ImageUrl = "~/img/icons/icon_warning.png";
                    imgStatus.AlternateText = "Atenção!";
                    pnStatusBar.Visible = true;

                    break;
                case StatusType.Success:
                    pnStatusBar.CssClass = "status success";
                    this.Caption = "Sucesso! ";
                    imgStatus.ImageUrl = "~/img/icons/icon_success.png";
                    imgStatus.AlternateText = "Sucesso!";
                    pnStatusBar.Visible = true;

                    break;
                case StatusType.Error:
                    pnStatusBar.CssClass = "status error";
                    this.Caption = "Erro! ";
                    imgStatus.ImageUrl = "~/img/icons/icon_error.png";
                    imgStatus.AlternateText = "Erro!";
                    pnStatusBar.Visible = true;
                    break;
                case StatusType.Information:
                    pnStatusBar.CssClass = "status info";
                    this.Caption = "Informação: ";
                    imgStatus.ImageUrl = "~/img/icons/icon_info.png";
                    imgStatus.AlternateText = "Informação";
                    pnStatusBar.Visible = true;

                    break;

            }

        }
    }

    public bool Modal
    {
        get { return _modal; }
        set
        {

            _modal = value;


            if (_modal)
            {

                Panel modal = new Panel();
                modal.CssClass = "modalStatus";
                modal.Controls.Add(pnStatusBar);
                HyperLinkCloseStatus.CssClass = "closeModalStatus";
                this.Controls.Add(modal);


            }

        }
    }

    public bool ShowClose
    {
        get { return _showClose; }
        set
        {
            _showClose = value;

            if (!_showClose)
            {

                HyperLinkCloseStatus.Visible = false;

            }

        }
    }

    public bool ShowOkButton
    {
        get { return _showOkButton; }
        set
        {
            _showOkButton = value;

            if (_showOkButton)
            {

                btAction.Visible = true;
            }

        }
    }

    #endregion

    #region " Load "

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    #endregion
}